package org.budo.mybatis.session.delegate;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.cursor.Cursor;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
import org.budo.support.mybatis.session.wrapper.SqlSessionWrapper;

/**
 * @author limingwei2
 * @see org.apache.ibatis.session.defaults.DefaultSqlSession
 */
@SuppressWarnings("rawtypes")
public abstract class AbstractSqlSessionDelegate extends SqlSessionWrapper {
    public AbstractSqlSessionDelegate(SqlSession sqlSession) {
        super(sqlSession);
    }

    /**
     * @see #select(String, ResultHandler)
     * @see #select(String, Object, ResultHandler)
     */
    public void select(String statement, Object parameter, RowBounds rowBounds, ResultHandler handler) {
        super.select(statement, parameter, handler);
    }

    /**
     * @see #selectList(String)
     * @see #selectList(String, Object)
     */
    public <E> List<E> selectList(String statement, Object parameter, RowBounds rowBounds) {
        return super.selectList(statement, parameter, rowBounds);
    }

    /**
     * @see #selectCursor(String)
     * @see #selectCursor(String, Object)
     */
    public <T> Cursor<T> selectCursor(String statement, Object parameter, RowBounds rowBounds) {
        return super.selectCursor(statement, parameter, rowBounds);
    }

    /**
     * @see #selectMap(String, String)
     * @see #selectMap(String, Object, String)
     */
    public <K, V> Map<K, V> selectMap(String statement, Object parameter, String mapKey, RowBounds rowBounds) {
        return super.selectMap(statement, parameter, mapKey, rowBounds);
    }

    /**
     * @see #selectOne(String)
     */
    public <T> T selectOne(String statement, Object parameter) {
        return super.selectOne(statement, parameter);
    }

    /**
     * @see #update(String)
     * @see #insert(String)
     * @see #insert(String, Object)
     * @see #delete(String)
     * @see #delete(String, Object)
     */
    public int update(String statement, Object parameter) {
        return super.update(statement, parameter);
    }

    public <T> T selectOne(String statement) {
        return this.<T> selectOne(statement, null);
    }

    public <K, V> Map<K, V> selectMap(String statement, String mapKey) {
        return this.selectMap(statement, null, mapKey, RowBounds.DEFAULT);
    }

    public <K, V> Map<K, V> selectMap(String statement, Object parameter, String mapKey) {
        return this.selectMap(statement, parameter, mapKey, RowBounds.DEFAULT);
    }

    public <T> Cursor<T> selectCursor(String statement) {
        return this.selectCursor(statement, null);
    }

    public <T> Cursor<T> selectCursor(String statement, Object parameter) {
        return this.selectCursor(statement, parameter, RowBounds.DEFAULT);
    }

    public <E> List<E> selectList(String statement) {
        return this.selectList(statement, null);
    }

    public <E> List<E> selectList(String statement, Object parameter) {
        return this.selectList(statement, parameter, RowBounds.DEFAULT);
    }

    public void select(String statement, Object parameter, ResultHandler handler) {
        this.select(statement, parameter, RowBounds.DEFAULT, handler);
    }

    public void select(String statement, ResultHandler handler) {
        this.select(statement, null, RowBounds.DEFAULT, handler);
    }

    public int insert(String statement) {
        return this.insert(statement, null);
    }

    public int insert(String statement, Object parameter) {
        return this.update(statement, parameter);
    }

    public int update(String statement) {
        return this.update(statement, null);
    }

    public int delete(String statement) {
        return this.update(statement, null);
    }

    public int delete(String statement, Object parameter) {
        return this.update(statement, parameter);
    }
}